<!--本页面为前台展现页面示例与规范，请研发人员仔细阅读-->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <!--除index.jsp外其它页面 title 均写英文文件名，不含后缀名-->
    <title>template</title>
    <!--所有页面均引入common.jsp -->
    <%@ include file="../include/common.jsp"%>
    <!--表格页面需要引入table.jsp -->
    <%@ include file="../include/table.jsp"%>
    <script type="text/javascript">
    window.onload = function() {
		setCenter(27, "center");
		setContent(25, "content");
		getPageMenu('div1_1', 'div1');
		PageMenuActive('div1_1', 'div1');
		changeRow_color("tab");
		changeRow_color("tab2");
	};
	window.onresize = function() {
		setCenter(27, "center");
		setContent(25, "content");
	};
	
	function datagrid(){
		$('#table').datagrid({
			width:1300,
			height:380,
			nowrap: false,
			striped: true,
			collapsible:true,
			url:'/bsm/config/hostConfigList.action',
			sortName: 'code',
			sortOrder: 'desc',
			remoteSort: false,
			idField:'code',
			frozenColumns:[[
                {field:'ck',checkbox:true},
                {title:'操作',field:'op',width:180,
                	formatter:function(value,rec){
						return '<input type="button" onclick="edit();" value="修改"><input type="button" onclick="datadelete();" value="删除"><input type="button" onclick="test();" value="测试">';
					}
	
                }
			]],
			columns:[[
				{field:'id',title:'id',width:120},
				{field:'ip',title:'主机IP',width:120},
				{field:'protocol',title:'远程方式',width:120,rowspan:2},
				{field:'port',title:'端口号',width:120,rowspan:2},
				{field:'username',title:'帐号',width:150,rowspan:2},
				{field:'prompt',title:'命令提示符',width:120,rowspan:2}
			]],
			pagination:true,
			rownumbers:true,
			toolbar:[{
				id:'btnadd',
				text:'新增',
				handler:function(){
					
				}
			},{
				id:'btncut',
				text:'批量删除',
				handler:function(){
					
					var ids = [];
					var rows = $("#table").datagrid('getSelections');
					alert(rows.length)
					for(var i=0;i<rows.length;i++){
						ids.push(rows[i].id);
					}
					
				}
			}]
		});
		
	}
	$(function(){
		datagrid();
	});
	function search(){
		var query={ip:$("#ip").val()}; //把查询条件拼接成JSON
		$("#table").datagrid('options').queryParams=query; //把查询条件赋值给datagrid内部变量
		$("#table").datagrid('reload'); //重新加载
	}
	function datadelete(){
		var selected = $('#table').datagrid('getSelected');
		if (selected){
				$.ajax({
							   type: "POST", 
							   url: "/bsm/config/deleteHostConfig.action", //请求的action
							   data: "id="+selected.id, //传的参数
							   dataType: 'html',
							   success: function(data){ //结果
								   $("#table").datagrid('reload'); //重新加载   
							   }
							   
						});
		}else{
			alert("请选中一条记录！");
		}

	}
    </script>
</head>
<body>
	<div id="iframeDiv" style="clear: both; height: 100%; width: 100%;">
    <!--仅index.jsp需要引入 index页面引入去掉../-->
    <%@ include file="../include/head.jsp" %>
    <!--end 仅index.jsp需要引入-->
    
        <div class="content">
            <div class="content_title_bg">
                <div class="content_title">
                    当前位置:一级菜单&gt;&gt;二级菜单（不显示当前位置去掉此部分）
                </div>
            </div>
            <div style="height: 100%; overflow: auto; padding: 0px;" id="center">
                <div class="tablabel">
                    <div id="div1_1" class="tab_show"
                        onclick="PageMenuActive('div1_1','div1')">
                        <span>查询框表格例子</span>
                    </div>
                    <div id="div1_2" class="tab_hide"
                        onclick="PageMenuActive('div1_2','div2')">
                        <span>表单输入例子</span>
                    </div>
                    <div id="div1_3" class="tab_hide"
                        onclick="PageMenuActive('div1_3','div3')">
                        <span>弹出窗口例子</span>
                    </div>
                </div>
                <div id="div1">
                   <div>
                   <fieldset>
                    
                     <table border="0" cellspacing="0" cellpadding="5" class="colorQuery">
                        <tr>
                        <th>主机IP:</th>
                        <td> <input type="text" name="hostIp" id="hostIp" value="" /></td>
  						<td>
		 				<input type="button" class="button" onclick="search();" value="查询">
  						</td>
  						</tr>
  						</table>
  					</fieldset>
  				 	</div>
  				<div>
  					<table id="table"></table>
  				</div>
                </div>

                <div id="div2" style="display: none">
                    <form id="centerForm" name="centerForm" action="" method="post">
                        <table class="form_main tableborder" border="0" cellpadding="5"
                            cellspacing="0" width="68%">
                            <tr>
                                <td class="label" width="30%">
                                    <span class="red">*</span> 中心IP:
                                </td>
                                <td class="input">
                                    <input type="text" id="centerIP" name="centerIP" maxlength="50"
                                        value="${centerIP }" />
                                </td>
                                <td class="desc" width="30%">
                                </td>
                            </tr>
                            <tr>
                                <td class="label" width="30%">
                                    <span class="red">*</span> 中心Socket端口:
                                </td>
                                <td class="input">
                                    <input type="text" id="centerSocket" name="centerSocket"
                                        maxlength="50" value="${centerSocket }" />
                                </td>
                                <td class="desc" width="30%">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="3" align="center">
                                    <input type="submit" value="提交" class="button"
                                        onmouseover="this.className='buttonhover'"
                                        onmouseout="this.className='button'" />
                                    <input type="reset" name="reset" value="重置" class="button"
                                        onmouseover="this.className='buttonhover'"
                                        onmouseout="this.className='button'" value="reset" />
                                    <div id="centermsg" class="red" style="display: none">
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
                <div id="div3" style="display: none">
                    <form id="notifyFrom" name="notifyFrom" action="" method="post">
                        <table class="form_main tableborder" border="0" cellpadding="5"
                            cellspacing="0" width="68%">
                            <tr>
                                <td class="label" width="30%">
                                    <span class="red">*</span> NotifyCenterIP:
                                </td>
                                <td class="input">
                                    <input type="text" id="notifyIP" name="notifyIP" maxlength="50"
                                        value="${notifyIP }" />
                                </td>
                                <td class="desc" width="30%">
                                </td>
                            </tr>
                            <tr>
                                <td class="label" width="30%">
                                    <span class="red">*</span> NotifyCenterSocket:
                                </td>
                                <td class="input">
                                    <input type="text" id="notifySocket" name="notifySocket"
                                        maxlength="50" value="${notifySocket }" />
                                </td>
                                <td class="desc" width="30%">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="3" align="center">
                                    <input type="submit" value="提交" class="button"
                                        onmouseover="this.className='buttonhover'"
                                        onmouseout="this.className='button'" />
                                    <input type="reset" name="reset" value="重置" class="button"
                                        onmouseover="this.className='buttonhover'"
                                        onmouseout="this.className='button'" value="reset" />
                                    <div id="notifymsg" class="red" style="display: none">
                                    </div>
                                </td>
                            </tr>

                        </table>
                    </form>
                </div>
            </div>
        </div>
	</div>
</body>
</html>